package com.wgchao.amc.repository.base;

import com.wgchao.amc.entity.base.SysBaseGr;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.Date;
import java.util.List;

/**
 * @作者  wgchao
 * @时间 2019-10-29 
 * @用途  
 */
@Repository
public interface SysBaseGrRepository  extends JpaRepository<SysBaseGr, Long>, JpaSpecificationExecutor<SysBaseGr> {

    @Modifying
    @Query("update SysBaseGr set del=true , delTime=?2 where groupId = ?1")
    void cancelByGroupId(Long groupId, Date time);

    SysBaseGr findFirstByRoleIdAndGroupId(Long roleId, Long groupId);

    SysBaseGr findFirstByRoleIdAndGroupIdAndDelIsFalse(Long roleId, Long groupId);

    List<SysBaseGr> findAllByGroupIdAndDelIsFalse(Long groupId);
}
